library(tidyverse)

repos <- readRDS('repositories.rds')

# actors
repos %>% 
  filter(!is.na(code)) %>% 
  group_by(code) %>% 
  summarise(
    n_actors = n_distinct(owner),
    n_repos = n(),
    p_repos = n_repos/nrow(repos %>% filter(!is.na(code)))
  ) %>% 
  arrange(desc(code))

# objectives
repos %>% 
  filter(!is.na(readme_code)) %>% 
  group_by(readme_code) %>% 
  summarise(n=n()) %>% 
  arrange(desc(n))


# licensing
repos %>% 
  filter(!is.na(code)) %>% 
  group_by(code) %>% 
  summarise(
    n = n(),
    
    n_license = sum(has_license, na.rm=T),
    p_license = n_license/n,
    
    n_mit = sum(license_mit, na.rm=T),
    p_mit = n_mit/n_license,
    
    n_gnu = sum(license_gnu, na.rm=T),
    p_gnu = n_gnu/n_license,
    
    n_apache = sum(license_apache, na.rm=T),
    p_apache = n_apache/n_license,
    
    n_other = sum(license_other, na.rm=T),
    p_other = n_other/n_license
  ) %>% 
  arrange(desc(n))
